<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-1.12.4.js"></script>
    <style>
        .aa{
            color: red;
        }
    </style>
</head>
<body>
帐号:<input id="userid" type="text" name="name" placeholder="请输入帐号" autocomplete="off"  value="gzs">

<br>
密码:<input id="userpass" type="password" name="pass" placeholder="请输入密码" autocapitalize="off" value="124053">
<span id="sp" class="aa">帐号或者密码错误</span>
<br>
<button type="button" id="login">login</button> <button type="button" id="adduser">adduser</button>


<script>
    $("#sp").hide();
    let login=document.querySelector("#login");


    login.addEventListener("click",function(){
        var userid=document.querySelector("#userid").value;
        var userpass=document.querySelector("#userpass").value;
        $.post("login.do","userid="+userid+"&userpass="+userpass,function (resp) {
            if(resp=="登录成功"){
                location.href="loginsucc.html";
            }else{

                $("#sp").show();
            }

        })
    })
    let adduser = document.querySelector("#adduser");
    adduser.addEventListener("click",function () {
        let userid = document.querySelector("#userid").value;
        let userpass=document.querySelector("#userpass").value;
        $.post("adduser.do","userid="+userid+"&userpass="+userpass,function (resp) {
            if(resp==1){
                alert("注册成功")
            }else{
                alert("注册失败")
            }

        })
    })
</script>
</body>
</html>